var ws,page = 1,uid,res = [],noMore = false;
var app = angular.module('app',[]);
app.controller('myController',function ($scope,$http) {
	$scope.initView = function () {
		if(noMore){return}
		$http({
			method: 'post',
			url: apiRoot,
			data: {
				action: 'Dynamic.getAllDynamic',
				uid:uid,
				page:page
			}
		}).then(function (result) {
			if(result.data.error == 0){
				if(result.data.data.dynamic.length == 0){
					noMore = true;
				}
				var info = result.data.data;
				var user = info['user'];/*个人信息*/
				$scope.nick = user.nick;
				$scope.icon = getAvatar(user.icon);
				res.push(info['dynamic']);
				$scope.info = res;/*动态*/
				console.log(JSON.stringify($scope.info));
			}else{
				toast(data.desc || '沒有数据');
			}
		},function () {
			errortoast();
		})
	};	
	
	$scope.comein = function (uid,type,id) {
		plus.webview.create('view_detail.html','view_detail.html',{},{noteUid:uid,type:type,noteId:id}).show('pop-in');
	}	
	
})

function readys(){
	ws = plus.webview.currentWebview();
	uid = ws.uid;
	var allocation = document.querySelector('[ng-controller=myController]');
	$scope = angular.element(allocation).scope();
	$scope.initView();
	$scope.$apply();
	
}

if(window.plus){
	readys();
}else{
	document.addEventListener('plusready',readys,false);
}